package com.guigu.gcservice.controller;

import com.guigu.commonutils.R;

import com.guigu.gcservice.entity.CircleJk;
import com.guigu.gcservice.entity.jikeng;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/gcservice/sl")
@CrossOrigin
public class suanliangController {



    // 不放坡或支挡土板基槽开挖
    @PostMapping("jk")
    public R jk(@RequestBody jikeng jikeng) {
        double V = jikeng.getV().doubleValue();
        double V1 = jikeng.getV1().doubleValue();
        double V2 = jikeng.getV2().doubleValue();
        double F = jikeng.getF().doubleValue();
        double L = jikeng.getL().doubleValue();
        double H = jikeng.getH().doubleValue();
        double K = jikeng.getK().doubleValue();
        double H1 = jikeng.getH1().doubleValue();
        double H2 = jikeng.getH2().doubleValue();
        System.out.println(H1);
        System.out.println(K);
        if(K==0.0 && H1==0.0){
            double v =F*H*L;   //不放坡
            jikeng.setV(v);
            System.out.println("v="+v);
        }else if (H1==0.0&&K>0.0){
            double v1 = (F+K)*H*L;   //放坡无垫层
            jikeng.setV1(v1);
            System.out.println("v1="+v1);
        }else if(H1>0.0&&K>0.0){
            double h2 =H-H1;
            jikeng.setH2(h2);
            double v2 =((F+K*h2)*h2+F*H1)*L;//放坡有垫层
            System.out.println("v2="+v2);
            jikeng.setV2(v2);
        }else if(H1>0.0&&K==0.0){
            double h2 =H-H1;
            jikeng.setH2(h2);
            System.out.println(h2);
            double v3 =(F*h2+F*H1)*L;//放坡有垫层
            jikeng.setV3(v3);
            System.out.println("v3="+v3);
        }






        return R.ok().data("jikeng",jikeng);
    }

     // 圆形基槽开挖
    @PostMapping("circle")
    public R circle(@RequestBody CircleJk CircleJk){
        double RA = CircleJk.getRA().doubleValue();
        double H = CircleJk.getH().doubleValue();
        double K = CircleJk.getK().doubleValue();
        if(K==0){
            double v = Math.pow(RA,2)*3.14*H;
            CircleJk.setV(v);
            System.out.println("v="+v);
        }else if(K>0){
            double r =K*H+RA;
            double va = 3.14*H*(Math.pow(RA,2)+RA*r+Math.pow(r,2));
            double v1 = va/3;
            CircleJk.setV1(v1);
            System.out.println("v1="+v1);
        }


        return R.ok().data("circle",CircleJk);
    }

}

